<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> 
<%
java.lang.String urlpath = request.getContextPath();
%>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>用户充值消费记录</title>
<meta http-equiv="expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
<link rel="stylesheet" href="../css/admin_style.css" />
<script type="text/javascript" src="../js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="../js/core/core.js"></script>
<script type="text/javascript" src="../js/pagination.js"></script>
<script type="text/javascript">

//check used
function showselect(type){
	var selects = get_tags(document,'select');
	for (i=0; i<selects.length; i++) {
		selects[i].style.visibility = type;
	}
}
function checkgroupset(chars){
	if (!confirm("确定删除吗? 如果您删除了此代理组,请到站点缓存数据管理更新代理头衔缓冲!")) return false;
	window.location.href = chars;return false;
}
function get_tags(parentobj,tag){
	if (typeof parentobj.getElementsByTagName!='undefined') {
		return parentobj.getElementsByTagName(tag);
	} else if (parentobj.all && parentobj.all.tags) {
		return parentobj.all.tags(tag);
	} else {
		return null;
	}
}
//other function
function atccheck(){
	if(document.FORM.atc_title.value==''){
		alert('标题为空');
		document.FORM.atc_title.focus();
		return false;
	} else if(document.FORM.fid.value==''){
		alert('没有选择文章所属分类');
		document.FORM.fid.focus();
		return false;
	}
	_submit();
}
function level_jump(admin_file){
	var URL=document.mod.selectfid.options[document.mod.selectfid.selectedIndex].value;
	location.href=admin_file+"?adminjob=level&action=editgroup&gid="+URL;
}
function ip_jump(name){
	URL = eval('document.form1.' + name + '.options[document.form1.' + name + '.selectedIndex].value');
	location.href=URL;
}
function pwJsCheck(_this,check,tagName){
	try{
		if (typeof tagName == 'undefined') tagName = "tr";
		if (typeof check == 'undefined') {
			if (typeof _this.checked == 'boolean') {
				check = _this.checked;
			} else {
				check = false;
			}
		}
		var o = _this.parentNode;
		var i = 3;
		while(i--){
			if (o.nodeName.toLowerCase() == tagName) {
				var className =  o.className.replace(/\s?td_bgC/ig, "");
				if (check) {
					className +=' td_bgC';
				}
				o.className = className;
				break;
			} else {
				o = o.parentNode;
			}
		}
	}catch(e){}
}
//Cookies Function
function getCookie(name) {
    var start = document.cookie.indexOf(name + '=');
    var len = start + name.length + 1;
    if ((!start) && (name != document.cookie.substring(0, name.length))) {
        return null;
    }
    if (start==-1) {
        return null;
    }
    var end = document.cookie.indexOf(';', len);
    if (end == -1) {
        end = document.cookie.length;
    }
    return unescape(document.cookie.substring(len,end));
}
function setCookie(name, value, expires, path, domain, secure) {
	if (!expires) {
		expires = new Date();
		expires.setTime(expires.getTime()+31536000);
	}
	document.cookie = name + '=' + escape(value) +
        ( (expires) ? ';expires=' + expires.toGMTString() : '') +
        'path=' + ( (path) ? path : '/') +
        ( (domain)  ? ';domain=' + domain : '') +
        ( (secure)  ? ';secure' : '');
}

function elementBind(type,id,stylename,csstext){
	var element = document.createElement(type);
	if (id) {
		element.id = id;
	}
	if (typeof(stylename) == 'string') {
		element.className = stylename;
	}
	if (typeof(csstext) == 'string') {
		element.style.cssText = csstext;
	}
	return element;
}
function addChild(parent,type,id,stylename,csstext){
	parent = objCheck(parent);
	var child = elementBind(type,id,stylename,csstext);
	parent.appendChild(child);
	return child;
}

function delElement(id){
	id = objCheck(id);
	id.parentNode.removeChild(id);
}
function objCheck(obj) {
	if (typeof(obj)=='string') {
		obj	= getObj(obj);
	}
	return obj;
}
document.onkeydown = function(e){
	var e = is_ie ? window.event: e;
	if ( e.keyCode==116) {
		window.location.reload();
		if (is_ie) {
			e.keyCode = 0;
       		e.cancelBubble = true;
		}
		return false;
	}
}

function openNewUrl(id,name,url){
	parent.PW.Dialog({
		'id': id,
		'name': name,
		'url': url
	}).loadIframe(url);
}

function changeType(type){
	$("#type").val(type);
	return true;
}
</script>

<script type="text/javascript">
var manageclass = {
	superdel : function (obj,forumid,step){
		var form = getObj(forumid);
		form.step.value = step;
		var page = obj.getAttribute("page");
		if(!page){
			page = getObj("input_page").value;
		}
		page = (page) ? page : 1;
		form.page.value = page;
		setTimeout(function(){
			form.submit();
		},0);
	}
}
onReady(function(){
	if(parent.adminNavClass){
		parent.adminNavClass.initTips();
	}
})
</script>
</head>
<body>
<div class="wrap">

<div class="nav3 mb10">
	<ul class="cc">
		<li class="current"><a href="userManagerUI?currentPage=1">代理管理</a></li>
		<sec:authorize ifAnyGranted="ROLE_ROOT,ROLE_ADMIN,ROLE_USER">
		<li><a href="toAddUser">添加代理</a></li>
		<!--  -->
		<li><a href="toBatchProduceOpen">产品批量修改</a></li>
		
		</sec:authorize>
    </ul>
</div>

<h2 class="h1"><b>用户消费总计</b></h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tr class="tr2 vt">
		<td class="td1">代理名</td>
		<td class="td2">${curUser.userAccount }</td>
        <td class="td1">代理状态</td>
		<td class="td2">
			<c:if test="${curUser.enabled==1 }">
				活动
			</c:if>
			<c:if test="${curUser.enabled==0 }">
				禁用
			</c:if>
		</td>
		 <td class="td1">注册时间</td>
		 <td class="td2">${curUser.registerTime }</td>
    </tr>
    <tr class="tr2 vt">
    	<td class="td1">账户余额</td>
    	<td class="td2">${curUser.money }</td>
    	<td class="td1">消费总额</td>
    	<td class="td2">${paginationSupport.totalCosumption }</td>
    	<td class="td1">充值总额</td>
    	<td class="td2">${paginationSupport.totleChongzhiMoney }</td>
    </tr>
     <tr class="tr2 vt">
    	<td class="td1">扣款总额</td>
    	<td class="td2">${paginationSupport.totleKoukuanMoney }</td>
    	<td class="td1">返利总额</td>
    	<td class="td2" colspan="3">${paginationSupport.totlefanliMoney }</td>
    </tr>
</table>
</div>

<form action="showUserConsumption" method="post">
<input type="hidden" name="curUserId"  value="${curUserId}"/>
<input type="hidden" name="type" id="type" value="${type}"/>
<h2 class="h1"><b>消费详情</b>
<button type="submit" onclick="return changeType(0)">混合</button>
<button type="submit" onclick="return changeType(1)">收入</button>
<button type="submit" onclick="return changeType(2)">支出</button>
</h2>
<div class="admin_table mb10">
<table width="100%" cellspacing="0" cellpadding="0">
	<tbody>
     <tr class="tr2 td_bgB">
		<td>序号</td>
		<td>收支类型</td>
        <td>发生金额</td>
        <td>订单(若有)</td>
        <td>订单类型(若有)</td>
        <td>描述</td>
		<td>操作人</td>
		<td>帐户余额</td>
		<td>发生时间</td>
	</tr>
	
	<c:forEach var='item' items='${paginationSupport.items}' varStatus='u'  step='1'>
	<tr class="tr1 vt">
		
		<td class="td2">
			<input type="hidden" value="${item.id }"/>
		${u.index+1}</td>
		<td class="td2">
			<c:if test="${item.type==0 }">
        	<span style="color:red">支出</span>
        	</c:if>
        	<c:if test="${item.type==1 }">
        	<span style="color:green">收入</span>
        	</c:if>
		</td>
		<td class="td2">${item.money }</td>
		<td class="td2">
			<c:if test="${item.userIndent!=null }">
        		${item.userIndent.id}
        	</c:if>
		</td>
		<td class="td2">
			<c:if test="${item.userIndent!=null }">
        		${item.userBaseIndent.baseIndentTypeClassify.name } -->> ${item.userBaseIndent.name }
        	</c:if>
		</td>
		
			 <c:if test="${item.userIndent!=null }">
        	<c:if test="${item.type==0&&item.type2!=4 }">
        		<td class="td2"><p class="lh_18" title="">用户【${item.indentCreateUser.userAccount }】生成订单【${item.userIndent.id}】，花费【${item.money }】</p></td>
        	</c:if>
        	<c:if test="${item.type==1&&item.type2!=4 }">
        		<td class="td2"><p class="lh_18" title="">用户【${item.indentCreateUser.userAccount }】完成订单【${item.userIndent.id}】，返利【${item.money }】</p></td>
        	</c:if>
        	<c:if test="${item.type==1&&item.type2==4 }">
        		<td class="td2"><p class="lh_18" title="">订单【${item.userIndent.id}】退款，返还【${item.money }】</p></td>
        	</c:if>
        	
        </c:if>
        <c:if test="${item.userIndent==null }">
        	<c:if test="${item.type==0 }">
        		<td class="td2"><p class="lh_18" title="">为用户【${item.user.userAccount }】充值划款，花费【${item.money }】</p></td>
        	</c:if>
        	<c:if test="${item.type==1 }">
        		<td class="td2"><p class="lh_18" title="">帐户充值</p></td>
        	</c:if>
        </c:if>
        <c:if test="${item.user==null }">
        	<td class="td2"><p class="lh_18" title="">admin</p></td>
        </c:if>
        <c:if test="${item.user!=null }">
        	<c:if test="${item.type==0 }">
        	<td class="td2"><p class="lh_18" title="">${curUser.userAccount }</p></td>
        	</c:if>
        	<c:if test="${item.type==1 }">
        	<td class="td2"><p class="lh_18" title="">${item.user.userName }</p></td>
        	</c:if>
        </c:if>
		 <td class="td2">${item.userAllMoney }</td>
		<td class="td2">${item.createDate }</td>
	</tr>
	</c:forEach>
</tbody></table>
</div>
<!--pages-->
<div id="pagination" style="width:100%;float:left;padding-bottom:26px;"></div>
<!--pages-->
</form>

<div class="c"></div>
</div>
<script type="text/javascript">
	

    if (typeof (HTMLElement) != "undefined" && !window.opera) {
    HTMLElement.prototype.__defineGetter__("outerHTML", function () {
        var a = this.attributes, str = "<" + this.tagName, i = 0; for (; i < a.length; i++)
            if (a[i].specified)
                str += " " + a[i].name + '="' + a[i].value + '"';
        if (!this.canHaveChildren)
            return str + " />";
        return str + ">" + this.innerHTML + "</" + this.tagName + ">";
    });
    HTMLElement.prototype.__defineSetter__("outerHTML", function (s) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df = r.createContextualFragment(s);
        this.parentNode.replaceChild(df, this);
        return s;
    });
    HTMLElement.prototype.__defineGetter__("canHaveChildren", function () {
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
    });
}
if (typeof (HTMLElement) != "undefined" && !window.opera) {
    HTMLElement.prototype.__defineGetter__("outerHTML", function () {
        var a = this.attributes, str = "<" + this.tagName, i = 0; for (; i < a.length; i++)
            if (a[i].specified)
                str += " " + a[i].name + '="' + a[i].value + '"';
        if (!this.canHaveChildren)
            return str + " />";
        return str + ">" + this.innerHTML + "</" + this.tagName + ">";
    });
    HTMLElement.prototype.__defineSetter__("outerHTML", function (s) {
        var r = this.ownerDocument.createRange();
        r.setStartBefore(this);
        var df = r.createContextualFragment(s);
        this.parentNode.replaceChild(df, this);
        return s;
    });
    HTMLElement.prototype.__defineGetter__("canHaveChildren", function () {
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
    });
}
</script>
<script type="text/javascript">
    var valueControls={//能直接用 obj.value赋值的控件名及Type
        "input":"text,password,hidden",
        "select":"select-one",
        "textarea":"textarea"
    };
    
    var formData={};
	formData["qe.email"]="";
	formData["qe.account"]="";
	formData["qe.linkman"]="";
	formData["qe.curBalance"]="";
	formData["qe.state"]="";
	formData["qe.qq"]="";
	formData["qe.regTimeStart"]="";
	formData["qe.params"]="[238]";
	formData["qe.userType"]="Agent";
	formData["qe.userGroupId"]="";
	formData["qe.regTimeEnd"]="";
	formData["qe.curUser"]="";
	formData["qe.selectHql"]="";
	formData["qe.countHql"]="select count(t.id) ";
	formData["qe.mobile"]="";
	formData["qe.orderby"]="asc";
	formData["qe.fromHql"]="from Agent t where 1=1 and t.id<\>1 and t.parent.id = ? order by t.id asc";
	formData["qe.password"]="";
	formData["qe.USERTYPE_ADMIN"]=" can\'t find \'getUSERTYPE_ADMIN\' method";
	formData["qe.USERTYPE_AGENT"]=" can\'t find \'getUSERTYPE_AGENT\' method";
    for(var id in formData){//铺数据
      var obj=document.getElementById(id);
      if(id && obj){//checkBox
        var tagName=obj.tagName.toLowerCase();
        if(obj.type){
          var type=obj.type.toLowerCase();
          if(valueControls[tagName] && valueControls[tagName].indexOf(type)!=-1){
            if(eval("document.getElementById(\""+id+"\")")){
              document.getElementById(id).value=formData[id];
            }
          }else{
             if(type=="radio" || type=="checkbox"){
              initRadioOrCheckBox(id); 
             }
             if(type=="select-multiple"){
              initMultiSelect(id);
             }
          }
        }else{
           obj.innerHTML=formData[id]; 
        }
      }
    }
    function initRadioOrCheckBox(id){
      var servingTimes=document.getElementsByName(id);
      for(var s=0;s<servingTimes.length;s++){
         if(servingTimes[s].type=="checkbox")
           servingTimes[s].checked=false;
      }
      if(formData[id]){
        var servingTimesValue=formData[id].split(",");
        for(var s=0;s<servingTimesValue.length;s++){
         for(var i=0;i<servingTimes.length;i++){
            if(servingTimes[i].value==servingTimesValue[s].trim())
            servingTimes[i].checked=true;
         }
       }
      }else{
       for(var i=0;i<servingTimes.length;i++){
         if(servingTimes[i].type=="checkbox")
           servingTimes[i].checked=true;
       }
      }
   }
   function initMultiSelect(id){
      var selOptions=document.getElementById(id).options;
      for( var i=0;i<selOptions.length;i++){
         selOptions.selected=false;
      }
      if(formData[id]){
        var selOptionsValue=formData[id].split(",");
        for(var s=0;s<selOptionsValue.length;s++){

         for(var i=0;i<selOptions.length;i++){
            if(selOptions[i].value==selOptionsValue[s].trim())
            selOptions[i].selected=true;
         }
       }
      }else{
       for(var i=0;i<selOptions.length;i++){
         selOptions[i].selected=false;
       }
      }
   }
</script>    
<script type="text/javascript">
function getQueryString(form,param) {
        var datastring = '';
        var inputs = form.getElementsByTagName('INPUT');
        for (var i = 0; i < inputs.length; i++) {
            if(inputs[i].name==param)continue;
            
            switch (inputs[i].getAttribute('type')) {
                case 'text':
                    datastring = plamostr(inputs[i], datastring);
                    break;
                case 'hidden':
                    datastring = plamostr(inputs[i], datastring);
                    break;
                case 'checkbox':
                    if (inputs[i].checked) {
                        datastring = plamostr(inputs[i], datastring);
                    }
                    break;
                case 'radio':
                    if (inputs[i].checked) {

                        datastring = plamostr(inputs[i], datastring);
                    }
                    break;
            }
        }
        var textareas = form.getElementsByTagName('TEXTAREA');
        for (var i = 0; i < textareas.length; i++) {
            datastring = plamostr(textareas[i], datastring);
        }
        var selectes = form.getElementsByTagName('SELECT');
        for (var i = 0; i < selectes.length; i++) {
            datastring = plamostr(selectes[i], datastring);
        }
        if(param){
            document.getElementById(param).value=datastring;
        }
       
        return datastring;
    }
    function plamostr(object, datastring) {
        /**
         *拼装Form数据字符串
         */
        if (datastring.length > 0) {
            datastring += '&' + object.getAttribute('name') + '=' + object.value;
        } else {
            datastring += object.getAttribute('name') + '=' + object.value;
        }
        return datastring;
    }
</script><script type="text/javascript" src="../js/global.js"></script>
<script type="text/javascript" src="../js/pw_ajax.js"></script>
<script type="text/javascript" src="../js/admin.js"></script>
<script type="text/javascript" src="../js/date.js"></script>
<script type="text/javascript" src="../js/plugin.js"></script>
<script type="text/javascript">
function showConfirm(info,href){
 info = info ;//+ "<br>操作理由：<input type='text' id='____operationReason'><br>操作密匙：<input type='text' id='____operationPassword'>";
 showDialog({type:"confirm",message:info,onOk:function(){
   //var ____operationReason=document.getElementById("____operationReason").value;
   //if(!____operationReason || ____operationReason==""){alert("请输入操作理由");return false;}
   location.href=href;
   //openNewUrl('user'+new Date().getTime(),info,href);
   return true;
 }});
}
var operations=document.getElementsByTagName("a");
for(var i=0;i<operations.length;i++){
    var obj=operations[i];
    var confirm=obj.getAttribute("confirm");
    if(!confirm || confirm!="yes")continue;
    obj.onclick=function(e){
        e=window.event||e;
        var el=e.srcElement;
        if(!el.getAttribute("confirmurl")){
		   el.setAttribute("confirmurl",el.href);
		   el.href="javascript:void(0);";
		};
        showConfirm("确认执行"+el.innerText+"操作？！",el.getAttribute("confirmurl"));
        return false;
    }
}

var allInputs = document.getElementsByTagName('input');
if(allInputs && allInputs.length>0){
	for(var i=0; i<allInputs.length;i++)
	{
		var ipt = allInputs[i].parentNode;
		if(ipt.tagName=='LI'&& allInputs[i].type=='radio')
		{
			allInputs[i].checked && (ipt.className='current');
			ipt.onclick = function(){radioWithWords(this)};
		}
	}
}
</script>
<script type="text/javascript">
    var currentPage = ${pageNum};
    var totalPage = ${paginationSupport.pageNum};
    var recordPerPage = ${paginationSupport.pageSize};
    var totalRecord = ${paginationSupport.totalCount};
    var turnToPath = "";
    var userId = ${curUser.userId};
    var type=$("#type").val();
    if(totalPage<1) totalPage=1
    turnToPath = "showUserConsumption";
    queryString = "curUserId="+${curUser.userId} + "&" +"pageNum=" + ${pageNum}+ "&" +"type=" + type;
    var pagination = new Pagination(currentPage, totalPage, recordPerPage, totalRecord, turnToPath, queryString);
    pagination.initPagination();
    var str = "showUserConsumption";
</script>
</body></html>
